package cn.csg.iotplatform.module.system.mq.consumer.dept;

import cn.csg.iotplatform.module.system.mq.message.dept.DeptProjectAttrChangeMessage;
import cn.csg.iotplatform.module.system.service.userdept.UserDeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class DeptProjectAttrChangeConsumer {

    @Resource
    private UserDeptService userDeptService;

    @EventListener
    @Async
    public void onMessage(DeptProjectAttrChangeMessage message) {
        log.info("[DeptProjectAttrChangeConsumer.onMessage][消息内容({})]", message);
        userDeptService.upadteAutoAuthChildDepts(message.isOnlyDelete(),message.getDeptIds());
    }
}
